package com.hsylient.adapter.controller;

import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.hsylient.adapter.adapter.PersonAdapter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class AdapterController {


    @GetMapping("/adapter")
    public void findPerson(@RequestParam String name) {

        PersonAdapter adapter = AdapterController.getAdapter(StrUtil.lowerFirst(name));
        log.info("姓名：{}", adapter.getName());
    }


    public static PersonAdapter getAdapter(String personType) {
        return SpringUtil.getBean(personType + "Adapter", PersonAdapter.class);
    }
}
